home *** CD-ROM | disk | FTP | other *** search
- ELECTRIC PHONE
-
- by Captain COMAL
-
- I'm late! I better call George. Drat!
- What's his last name? Klaverston. No.
- Calverson? Wait! Why bother? You have
- a computer. COMAL is good at
- searching for things. This program
- does it all for you: creates the data
- file, let's you enter names into it,
- and best of all - finds a phone
- number when you need it. And you
- don't have to remember the persons
- full name either!
-
- The find routine is simple. It is
- really done all in one line using IN
- (see line 540). The nice thing is
- that IN looks over the entire string
- for a match! To find the name George
- Galveston you could ask for George
- and it would match. Or ask for Galv,
- ston, or just G. They all will match.
-
- And keeping track of your disk files
- with COMAL is easy too. The STATUS
- command reports on the status of the
- disk drive (see line 380). We use it
- to see if opening the file was OK
- ("00"). The first time you run the
- program the data file will not be
- there, and the program detects this
- and starts it for you. COMAL watches
- all your files for you. Whenever you
- reach the end of a file it sets EOF
- (for End Of File) to TRUE. By using
- EOF in line 520 we make sure our
- program is not upset if it can't find
- the person requested.
-
- Did you see the ZONE command in line
- 50? In BASIC your screen is set up
- with a default zone width of 10,
- which is nice, if you happen to need
- that specific setting. In COMAL, you
- can set the zone to be any number you
- wish (0 is the default for none).
- Line 50 sets the zone to 21, perfect
- for use with names up to 20
- characters long (which we set in line
- 20). Longer names then have the phone
- number on the next line (since two
- tabs of 21 is past the 40 character
- screen line).
-
- Finally, look at the multiple choice
- system COMAL has. Lines 140 through
- 270 show the CASE structure. KEY$
- looks at the keyboard and returns the
- key you just pressed (if any). It is
- the basis of our CASE. When the key
- is an E (upper or lower case) the
- ENTER'NAME routine is executed. When
- it is F the program first asks for a
- piece of information (what to look
- for) and then calls the routine
- FIND'NAME to do the search. If none
- of the WHEN cases match, COMAL
- provides us with the OTHERWISE
- section. All quite readable.
-